/*
 * @Description:
 * @Author: fhw
 * @Date: 2023-02-03 15:31:55
 */
/* eslint-disable @typescript-eslint/no-empty-function */
import { App, defineComponent, PropType, ref, Plugin } from 'vue'
import { rowArray } from '../utils/publicMethod'
import { commonly } from '../utils/publicMethod'
import { useSearch } from '@/hooks'
import { wmsPageSize } from '../utils/system'

const propsData = {
	row: {
		required: true,
		type: Array as PropType<Array<rowArray>>,
		default() {
			return []
		},
	},
}
const FSearchModel = defineComponent({
	name: 'r-searchModel',
	props: propsData,
	setup(props, { expose }) {
		// const defaultParams = ordersColumn([['create_time', false]])
		const { expand, expandToggle, searchForm } = useSearch<ObjectMap>({})
		const pageSate = ref({})

		const { searchSlots, rSearch, rClear, rSearchData } = commonly({
			pageSate,
			searchForm,
			searchRows: props.row,
			run: () => {},
			getPagination: () => {},
			...wmsPageSize,
		})

		expose({ rSearch, rSearchData })
		return () => (
			<r-search
				labelCol={{ span: 7 }}
				wrapperCol={{ span: 15 }}
				searchKey="systemForecastSearch"
				clear={rClear}
				search={rSearch}
				expand={{
					value: expand.value,
					expandToggle,
				}}
				v-slots={{
					...searchSlots(true),
				}}
				model={searchForm.value}
				rows={props.row}
			/>
		)
	},
})
FSearchModel.install = function (app: App) {
	app.component(FSearchModel.name, FSearchModel)
	return app
}
export default FSearchModel as typeof FSearchModel & Plugin
